package com.shujia

import scala.io.{BufferedSource, Source}

object Demo4FIleRead {
  def main(args: Array[String]): Unit = {
    //读取文件
    //BufferedSource相当于缓冲输入流
    val source: BufferedSource = Source.fromFile("scala/data/students.csv")
    //读取所有行返回一个迭代器（按行读取）
    val iter: Iterator[String] = source.getLines()
    //将迭代器转换成集合
    val students: List[String] = iter.toList
    println(students)

    for (student <- students) {
      println(student)
    }
  }

}
